//-*-Igor-*-
// ###################################################################
// Igor Pro - JEG Image Tools
//
//	FILE: "JEG Path Names"
//									  created: 9/25/96 {4:02:51 PM} 
//								  last update: 11/25/99 {10:40:03 AM} 
//	Author:	Jonathan Guyer
//  E-mail: <jguyer@his.com>
//     WWW: <http://www.his.com/~jguyer/>
//	
//	Description: 
//		Tools to extract parts of file paths
// 
//	History
// 
//	modified by	 rev reason
//	-------- --- --- -----------
//	10/31/98 JEG 1.0 original
// ###################################################################

#pragma rtGlobals=1		// Use modern global access method.


//
// -------------------------------------------------------------------------
//	 
// "JEG_FileTail"	--
//	
//  Returns all of the characters in name after the last colon.
//  If name contains no colons, then returns name.
// -------------------------------------------------------------------------
//
Function/S JEG_FileTail(file)
	String file
	
	return file[JEG_LastColon(file) + 1, Inf]
End

Function/s JEG_FileDirectory(file, fullPath)
	String   file
	Variable fullPath
	
	String result = file[0, JEG_LastColon(file) - 1]
	
	if (!fullPath)
		result = JEG_FileTail(result)
	endif
	
	return result
End

Function JEG_LastColon(file)
	String file
	
	Variable p1 = -1, p2 = -1
	do
		p2 = strsearch( file, ":", p1 + 1 )
		if (p2 >= 0 )
			p1 = p2
		endif
	while (p2 >= 0)
	
	return p1
End